package cn.edu.swu.toy;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.List;

public class ToyService {

    private ToyRepo repo;
    public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd");

    public ToyService(){
    }

    public List<Toy> getAll() throws SQLException, ClassNotFoundException {
        return this.repo.getAllToys();
    }



    public void save(Toy toy) throws SQLException {
        this.repo.save(toy);
    }

    public void deleteById(int id) throws SQLException {
        this.repo.deleteById(id);
    }

    public Toy getById(int id) throws SQLException {
        return this.repo.getById(id);
    }



    public List<Toy> search(String key) throws SQLException {
        return this.repo.search(key);
    }

    public void setRepo(ToyRepo repo) {
        this.repo = repo;
    }


}
